package com.example.demo.mapper.entity;

import lombok.Data;

import javax.persistence.Id;
import javax.persistence.Table;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author Lucy
 * @create 2024-01-28 20:44
 */
@Data
@Table(name="sys_user")
public class User {
    @Id
    private int userId;

    private String number;

    private String name;

    private String password;

    private String avatar;

    private String phone;

    private String email;

    private int schoolId;

    private int loginFailures;

    private int state;

    private Date createTime;

    private boolean isRemeber;

    public boolean getIsRemeber() {
        return isRemeber;
    }

    public void setNumber(int roleId) {
        // 生成随机数
        int randomNumber = (int) ((Math.random() * 100000000) + 1);
        // 获取当前时间作为前缀
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
        String datePrefix = sdf.format(new Date());
        // 拼接用户编号
        number = String.valueOf(roleId) + datePrefix + String.format("%07d", randomNumber);
    }



}
